﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame.Input
{
	public class WorkInputFactory : IInputFactory
	{
		private KeyboardState currKeyboardState;
		private KeyboardState prevKeyboardState;

		public void Update(GameTime gameTime)
		{
			prevKeyboardState = currKeyboardState;
			currKeyboardState = Keyboard.GetState();
		}

		public Boolean Escape()
		{
			return currKeyboardState.IsKeyDown(Keys.Escape);
		}
		public Boolean Toggle()
		{
			return KeyPress(Keys.Space);
		}
		public Boolean Load()
		{
			return KeyPress(Keys.Enter);
		}

		private Boolean KeyPress(Keys key)
		{
			return currKeyboardState.IsKeyDown(key) && prevKeyboardState.IsKeyUp(key);
		}
	}
}